<%--
  Created by IntelliJ IDEA.
  User: 风间琉璃
  Date: 2021/5/17
  Time: 15:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
  <head>
    <title>$Title$</title>
    <script src="${pageContext.request.contextPath}/statics/js/jquery-1.8.3.js"></script>
    <script>
      <c:if test="${empty list}">
      location.href="${pageContext.request.contextPath}/handSet/list";
      </c:if>
    </script>
  </head>
  <body>
    <table>
      <tr>
        <th>手机信息</th>
      </tr>
      <tr>
        <th>品牌型号</th>
        <th>参考报价</th>
        <th>操作</th>
      </tr>
      <c:forEach items="${list}" var="handset" varStatus="status">
<%--        <c:if test="${status.index % 2 == 0}">style="background-color:red;"</c:if>--%>
        <tr>
          <td>${handset.nameType}</td>
          <td>${handset.price}</td>
          <td><a class="select" href="${pageContext.request.contextPath}/handSet/one?hsId=${handset.hsId}" style="margin-right: 10px">详情</a>
            <a class="del" href="javascript:void(0)" hsId="${handset.hsId}">删除</a></td>
        </tr>
      </c:forEach>
    </table>
  <script>
    $(".del").click(function (){
      var isDel = confirm("是否删除？");
      var hsId = $(this).attr("hsId");
      var delNode = $(this).parent().parent();
      if (isDel === true){
        $.get("${pageContext.request.contextPath}/handSet/del","hsId="+hsId,function (data){
          if (data > 0){
            delNode.remove();
          }
          alert("删除成功！");
        })
      }

    })
  </script>
  </body>
</html>
